<template>
	<view class="speak-list-box">
		<view class="speak-num">评论 {{total}}</view>
		<view class="talk-list">
			<view class="talk-item" v-for="(item, index) in dataList" :key="index">
				<view class="user-info-box">
					<u-avatar @click="userCenter(item)" :src="item.avatar"></u-avatar>
					<view class="user-speak-box" :class="index===dataList.length-1?'':'weui-cell'">
						<view class="user-info">
							<view class="user-name-box">
								<view class="user-name">{{item.nickName}}</view>
								<view class="sex-box-nv" v-if="item.sex == 1">
									<u-icon name="ziyuan2" custom-prefix="iconfont"></u-icon>
									<view class="age-text">{{item.age}}</view>
								</view>
								<view class="sex-box" v-else>
									<u-icon name="ziyuan3" custom-prefix="iconfont"></u-icon>
									<view class="age-text">{{item.age}}</view>
								</view>
							</view>
							<view class="user-name-box">
								<view class="user-tag-box">
									<view class="user-tag">IP:{{item.city}}</view>
									<!-- <u-line length="22rpx" margin="10px" direction="col"></u-line>
									<view class="user-tag">1.2km</view> -->
								</view>
							</view>
						</view>
						<view class="content-box">
							<view class="text-box" @longpress="sheet(item)" @click="chat(item,index)">
								<rich-text :nodes="item.content"></rich-text>
							</view>
						</view>
						<view class="time-box">
							<view class="time-text">{{item.time}}</view>
							<view class="toolbar" @click="thumb(item,index)">
								<u-icon name="thumb-up" size="38"></u-icon>
								<view class="toolbar-text">{{item.giveNum}}</view>
							</view>
						</view>
						<reply ref="reply" @reply="reply" :commentId="item.id" :noticeCommentId="item.noticeCommentId" :total="item.total-3" :dataList="item.replyList"></reply>
					</view>
				</view>
			</view>
		</view>
		<u-action-sheet :list="list" @click="sheetClick" v-model="show"></u-action-sheet>
	</view>
</template>

<script>
	export default {
		props: {
			dataList: {
				// 动态数据
				type: Array,
				default () {
					return []
				}
			},
			total: {
				type: Number,
				default: 0
			}
		},
		data() {
			return {
				list: [{
					text: '删除评论',
				}],
				commentId: '-1',
				show: false
			}
		},
		created() {
			this.init();
	    },
		methods: {
			init() {
				
			},
			load(i) {
				this.$refs.reply[i].load();
			},
			addUnshift(i, data) {
				this.$refs.reply[i].addUnshift(data);
			},
			sheetClick() {
				this.$emit('commentRemove', this.commentId);
			},
			chat(item,index) {
				this.$emit('chat',item,index);
			},
			sheet(item) {
				var userId = uni.getStorageSync("userId");
				if(item.userId == userId){
					this.show = true;
					this.commentId = item.id;
				}
			},
			thumb(e,i) {
				this.$emit('thumb',e,i);
			},
			userCenter(item) {
				if(this.my){
					return;
				}
				
				this.judgeLogin(() => {
					this.$u.route({
						url: 'packgeMine/pages/center/index',
						params: {
							userId: item.userId,
						}
					});
				});
			},
			more() {
				this.$emit('more');
			},
			reply(e) {
				this.$emit('reply',e);
			}
		}
	}
</script>

<style lang="scss" scoped>
	.speak-list-box {
		padding: 15px;
		border-top: 1px solid #ddd;
	}
	.speak-num {
		font-size: 28rpx;
		color: #303133;
		font-weight: bolder;
	}
	.talk-list {
	}
	.talk-item {
		padding-bottom: 5px;
	}
	
	.weui-cell {
	  position: relative;
	}
	
	.weui-cell:after {
	    content: " ";
	    position: absolute;
	    left: 0;
	    bottom: 0;
	    right: 0;
	    height: 1px;
	    border-bottom: 1px solid #e5e5e5;
	    color: #e5e5e5;
	    -webkit-transform-origin: 0 0;
	    transform-origin: 0 0;
	    -webkit-transform: scaleY(0.5);
	    transform: scaleY(0.5);
	    z-index: 2;//看情况使用
	}
	
	.user-speak-box {
		margin-left: 10px;
		display: flex;
		flex-direction: column;
		flex: 1;
	}
	
	.user-info-box {
		display: flex;
		margin-left: 10rpx;
		padding-top: 15px;
		margin-right: 10rpx;
	}
	.user-info {
		display: flex;
		flex-direction: column;
		margin-top: 3px;
		flex: 1;
		margin-bottom: 5px;
	}
	.user-name {
		font-size: 28rpx;
		margin-right: 5px;
	}
	.user-woman {
		background-color: #e8bebe;
		display: flex;
		align-items: center;
		border-radius: 100%;
		padding: 3px;
	}
	
	.user-man {
		background-color: #a9c5e2;
		display: flex;
		align-items: center;
		border-radius: 100%;
		padding: 3px;
	}
	.user-name-box {
		display: flex;
		align-items: center;
	}
	.user-tag-box {
		display: flex;
		align-items: center;
	}
	.user-tag {
		font-size: 10px;
		color: #82848a;
		line-height: 70rpx;
	}
	.menu-box {
		display: flex;
	}
	.content-box {
		margin: 10px 0;
		margin-bottom: 0;
	}
	.text-box {
		white-space: pre-wrap;
	}
	.toolbar {
		display: flex;
		align-items: center;
		margin-left: 20px;
		color: #82848a;
	}
	.toolbar-text {
		font-size: 26rpx;
		margin-left: 5px;
	}
	.time-box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin-top: 10px;
		margin-bottom: 15px;
	}
	.time-text {
		font-size: 26rpx;
		color: #82848a;
	}
	.sex-box {
		background-color: #2b85e4;
		display: flex;
		color: #fff;
		padding: 2px 5px;
		border-radius: 20px;
		font-size: 8px;
	}
	.sex-box-nv {
		background-color: #fe709f;
		display: flex;
		color: #fff;
		padding: 2px 5px;
		border-radius: 20px;
		font-size: 8px;
	}
	.age-text {
		margin-left: 2px;
	}
</style>
